﻿Imports System.Text.RegularExpressions
Public Class frmEditEmployee
    Public dir As String = "D:\INTROSE Project\GUI\GUI\Resources\"
    Dim r As New Regex("[:-~]")
    Dim r2 As New Regex("[!-/]")
    Dim r3 As New Regex("[0-9]")
    Dim r4 As New Regex("[A-Za-z]")
    Dim r5 As New Regex("[:-@]")
    Dim r6 As New Regex("[{-~]")
    Dim r7 As New Regex("[[-`]")

    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click

    End Sub

    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click

    End Sub

    Private Sub cmdBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBack.Click
        Me.Close()
        frmMain.Show()
    End Sub

    Private Sub cmdInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdInsert.Click
        OpenFileDialog1.Title = "Please Select Image"
        OpenFileDialog1.InitialDirectory = "C:"
        OpenFileDialog1.ShowDialog()
        If (OpenFileDialog1.FileName.ToString = "") Then
            PictureBox1.Image = System.Drawing.Image.FromFile(dir + "images.jpg")
        Else
            PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName.ToString)
        End If
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        Dim strm As System.IO.Stream
        strm = OpenFileDialog1.OpenFile()
    End Sub

    Private Sub txtEmpID_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEmpID.TextChanged
        If txtEmpID.Focused = True Then
            If (txtEmpID.Text.Length = 0) Then
                pbErrEmpID.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpID.Text = "Employee ID field is blank"
                lblErrEmpID.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmpID.Text, r.ToString)) Then
                pbErrEmpID.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpID.Text = "Employee ID field is Invalid"
                lblErrEmpID.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmpID.Text, r2.ToString)) Then
                pbErrEmpID.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpID.Text = "Employee ID field is Invalid"
                lblErrEmpID.ForeColor = Color.Red
            Else
                pbErrEmpID.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrEmpID.Text = "Employee ID field is valid"
                lblErrEmpID.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub txtEmpName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEmpName.TextChanged
        If (txtEmpName.Focused = True) Then
            If (txtEmpName.Text.Length = 0) Then
                pbErrEmpName.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpName.Text = "Employee Name field is blank"
                lblErrEmpName.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmpName.Text, r5.ToString)) Then
                pbErrEmpName.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpName.Text = "Employee Name field is Invalid"
                lblErrEmpName.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmpName.Text, r2.ToString)) Then
                pbErrEmpName.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpName.Text = "Employee Name field is Invalid"
                lblErrEmpName.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmpName.Text, r3.ToString)) Then
                pbErrEmpName.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpName.Text = "Employee Name field is Invalid"
                lblErrEmpName.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmpName.Text, r6.ToString)) Then
                pbErrEmpName.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpName.Text = "Employee Name field is Invalid"
                lblErrEmpName.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmpName.Text, r7.ToString)) Then
                pbErrEmpName.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmpName.Text = "Employee Name field is Invalid"
                lblErrEmpName.ForeColor = Color.Red
            Else
                pbErrEmpName.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrEmpName.Text = "Employee Name field is valid"
                lblErrEmpName.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub txtAddress_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAddress.TextChanged
        If (txtAddress.Focused = True) Then
            If (txtAddress.Text.Length = 0) Then
                pbErrAddress.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrAddress.Text = "Address field is blank"
                lblErrAddress.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtAddress.Text, "^" + r4.ToString)) Then
                pbErrAddress.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrAddress.Text = "Address field is invalid"
                lblErrAddress.ForeColor = Color.Red
            Else
                pbErrAddress.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrAddress.Text = "Address field is valid"
                lblErrAddress.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub txtEmail_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEmail.TextChanged
        If (txtEmail.Focused = True) Then
            If (txtEmail.Text.Length = 0) Then
                pbErrEmail.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmail.Text = "Email Address field is blank"
                lblErrEmail.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtEmail.Text, "^" + r3.ToString)) Then
                pbErrEmail.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrEmail.Text = "Email Address field is invalid"
                lblErrEmail.ForeColor = Color.Red
            Else
                pbErrEmail.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrEmail.Text = "Email Address field is valid"
                lblErrEmail.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub txtContact_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtContact.TextChanged
        If (txtContact.Focused = True) Then
            If (txtContact.Text.Length = 0) Then
                pbErrContact.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrContact.Text = "Contact/s field is blank"
                lblErrContact.ForeColor = Color.Red
            ElseIf (Regex.IsMatch(txtContact.Text, r4.ToString)) Then
                pbErrContact.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrContact.Text = "Contact/s field is invalid"
                lblErrContact.ForeColor = Color.Red
            Else
                pbErrContact.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrContact.Text = "Contact/s field is valid"
                lblErrContact.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub cbPosition_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbPosition.SelectedIndexChanged
        If (cbPosition.Focused = True) Then
            If (cbPosition.Text.Length = 0) Then
                pbErrPosition.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrPosition.Text = "Please choose from the combo box"
                lblErrPosition.ForeColor = Color.Red
            Else
                pbErrPosition.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrPosition.Text = "Posiition field is valid"
                lblErrPosition.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub txtSecond_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSecond.TextChanged
        If (txtSecond.Focused = True) Then
            If (txtSecond.Text.Length = 0) Then
                pbErrSecond.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrSecond.Text = "Secondary field is blank"
                lblErrSecond.ForeColor = Color.Red
            Else
                pbErrSecond.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrSecond.Text = "Secondary field is valid"
                lblErrSecond.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub txtTertiary_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTertiary.TextChanged
        If (txtTertiary.Focused = True) Then
            If (txtTertiary.Text.Length = 0) Then
                pbErrTertiary.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrTertiary.Text = "Tertiary field is blank"
                lblErrTertiary.ForeColor = Color.Red
            Else
                pbErrTertiary.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrTertiary.Text = "Tertiary field is valid"
                lblErrTertiary.ForeColor = Color.Green
            End If
        End If
    End Sub

    Private Sub txtSkill_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSkill.TextChanged
        If (txtSkill.Focused = True) Then
            If (txtSkill.Text.Length = 0) Then
                pbErrSkill.Image = System.Drawing.Image.FromFile(dir + "x_mark.png")
                lblErrSkill.Text = "Skill/s field is blank"
                lblErrSkill.ForeColor = Color.Red
            Else
                pbErrSkill.Image = System.Drawing.Image.FromFile(dir + "check_mark.png")
                lblErrSkill.Text = "Skill/s field is valid"
                lblErrSkill.ForeColor = Color.Green
            End If
        End If
    End Sub
End Class